//
//  ForGoodFooter.m
//  HMMarket
//
//  Created by 孙鹏飞 on 2017/6/26.
//  Copyright © 2017年 homai. All rights reserved.
//

#import "ForGoodFooter.h"

@interface ForGoodFooter()

@property (weak, nonatomic) IBOutlet UIButton *confirmGoodBtn;

@property (weak, nonatomic) IBOutlet UIButton *cancleBtn;

@property (weak, nonatomic) IBOutlet UIButton *returnGoodBtn; // 申请退货

@property (weak, nonatomic) IBOutlet UIButton *returnOfBtn; // 退货中

@property (weak, nonatomic) IBOutlet UIButton *returnOkBtn; // 退货完成

@end

@implementation ForGoodFooter

+ (instancetype)orderFooter
{
    return [[[NSBundle mainBundle] loadNibNamed:NSStringFromClass(self) owner:nil options:nil] lastObject];
}

- (void)awakeFromNib
{
    [super awakeFromNib];
    
    _confirmGoodBtn.layer.borderColor = kMainColor.CGColor;
    _confirmGoodBtn.layer.borderWidth = 1;
    _confirmGoodBtn.layer.cornerRadius = 17;
    _confirmGoodBtn.layer.masksToBounds = YES;
    
    _returnGoodBtn.layer.borderColor = kMainColor.CGColor;
    _returnGoodBtn.layer.borderWidth = 1;
    _returnGoodBtn.layer.cornerRadius = 17;
    _returnGoodBtn.layer.masksToBounds = YES;
    
    _returnOfBtn.layer.borderColor = kMainColor.CGColor;
    _returnOfBtn.layer.borderWidth = 1;
    _returnOfBtn.layer.cornerRadius = 17;
    _returnOfBtn.layer.masksToBounds = YES;
    
    _returnOkBtn.layer.borderColor = kMainColor.CGColor;
    _returnOkBtn.layer.borderWidth = 1;
    _returnOkBtn.layer.cornerRadius = 17;
    _returnOkBtn.layer.masksToBounds = YES;
    
    _cancleBtn.layer.borderColor = kMainColor.CGColor;
    _cancleBtn.layer.borderWidth = 1;
    _cancleBtn.layer.cornerRadius = 17;
    _cancleBtn.layer.masksToBounds = YES;
}

- (void)setModel:(OrderModel *)model
{
    _model = model;
    
    NSLog(@"return_order -- >%@",_model.return_order);
    
    if ([_model.return_order isEqualToString:@"1"]) {
        _returnGoodBtn.hidden = YES;
        _returnOfBtn.hidden = NO;
        _returnOkBtn.hidden = YES;
        _cancleBtn.hidden = YES;
    } else if ([_model.return_order isEqualToString:@"2"]) {
        _returnGoodBtn.hidden = YES;
        _returnOfBtn.hidden = YES;
        _returnOkBtn.hidden = NO;
        _cancleBtn.hidden = YES;
    } else {
        _returnGoodBtn.hidden = NO;
        _returnOfBtn.hidden = YES;
        _returnOkBtn.hidden = YES;
        _cancleBtn.hidden = NO;
    }
}


- (IBAction)confirmGoodBtnClick:(id)sender {
    if ([_delegate respondsToSelector:@selector(ForGoodFooter:didClickedConfirmGoodBtn:)]) {
        [_delegate ForGoodFooter:self didClickedConfirmGoodBtn:_model];
    }
}

- (IBAction)cancleBtnClick:(id)sender {
    if ([_delegate respondsToSelector:@selector(ForGoodFooter:didClickedCancleBtn:)]) {
        [_delegate ForGoodFooter:self didClickedCancleBtn:_model];
    }
}

- (IBAction)returnGoodBtnClick:(id)sender {
    if ([_delegate respondsToSelector:@selector(ForGoodFooter:didClickedReturnGoodBtn:)]) {
        [_delegate ForGoodFooter:self didClickedReturnGoodBtn:_model];
    }
}

- (IBAction)returnOfBtnClick:(id)sender {
    if ([_delegate respondsToSelector:@selector(ForGoodFooter:didClickedReturnOfBtn:)]) {
        [_delegate ForGoodFooter:self didClickedReturnOfBtn:_model];
    }
}

- (IBAction)returnOkBtnClick:(id)sender {
    if ([_delegate respondsToSelector:@selector(ForGoodFooter:didClickedReturnOkBtn:)]) {
        [_delegate ForGoodFooter:self didClickedReturnOkBtn:_model];
    }
}


@end
